import java.time.LocalDate;
import java.time.Period;

public class PeriodTest {
    /*
    掌握Period的作用：计算两个日期相差的年数、月数、天数
     */
    public static void main(String[] args) {
        LocalDate start = LocalDate.of(2019, 1, 1);
        LocalDate end = LocalDate.of(2019, 1, 5);

        // 创建Period对象,封装两个日期对象
        Period period = Period.between(start, end);

        System.out.println(period.getYears());
        System.out.println(period.getMonths());
        System.out.println(period.getDays());
    }
}
